﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Nivdal.AuxCode;
using System.Threading;
using System.Globalization;

namespace Nivdal
{
    public partial class Premium : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            OnlineUser ou = (OnlineUser)Session["User"];
            if (!IsPostBack)
            {
                if (!HttpContext.Current.User.Identity.IsAuthenticated)
                    Response.Redirect("~/Default.aspx");
                this.PremiumInfoDS.SelectParameters.Add("UserId", ou.UserId);

            }
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
                Response.Redirect("~/Default.aspx");
            this.Title = Resources.Resource.Global_PremiumUser + ", " + Resources.Resource.Shop_PageTitle;

            PremiumExplanationPart1.Text = FormatString(Resources.Resource.Premium_ExplanationPart1);
            PremiumExplanationPart2.Text = FormatString(Resources.Resource.Premium_ExplanationPart2);

            if (!ou.PremiumEnabled)
            {
                try
                {
                    (CurrenrPremiumInfo.FindControl("CurrenrPremiumInfo") as HyperLink).Visible = false;
                    RenewOptionsLink2.Visible = false;
                }
                catch { }
            }
             
        }

        protected override void InitializeCulture()
        {
            OnlineUser ou = (OnlineUser)Session["User"];
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(ou.UICulture);
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ou.Culture);
        }

        protected string FormatString(string str)
        {
            return str.Replace("\r\n", "<br />").Replace("\n", "<br />");
        }

    }
}